import { request } from '@/utils/request'
import type { SettingListParam, SettingResult, AddSettingParam, AddSettingResult } from '@/types/setting'

// 获取角色列表
export const getRoleListApi = (params: SettingListParam) => {
  return request<SettingResult>('/sys/role', 'GET', params)
}

// 删除角色
export const delRoleApi = (id: string) => {
  return request(`/sys/role/${id}`, 'DELETE')
}

// 新增角色
export const addRoleApi = (data: AddSettingParam) => {
  return request('/sys/role', 'POST', data)
}

// 获取角色详情
export const getRoleDetailApi = (id: string) => {
  return request<AddSettingResult>(`/sys/role/${id}`)
}

// 更新角色
export const updateRoleApi = (data: AddSettingResult) => {
  return request(`/sys/role/${data.id}`, 'PUT', data)
}

// 给角色分配权限
export const assginPermApi = (data: { id: string; permIds: string[] }) => {
  return request(`/sys/role/assignPrem`, 'PUT', data)
}
